﻿using System;
using System.Drawing;

namespace MarioMapEditor
{
    class ObCastle:ObObject
    {
        public enum Castle {Big =25, Small};

        protected int WidthBig;
        protected int HeightBig;

        public ObCastle()
        {
            WidthBig    = 7;
            HeightBig   = 7;
            Width       = 5;
            Height      = 5;
        }

        public ObCastle(Castle nID)
        {
            ID          = (int)nID;
            WidthBig    = 7;
            HeightBig   = 7;
            Width       = 5;
            Height      = 5;
        }

        public override bool SetID(int nID)
        {
            if (checkType(nID))
            {
                ID = nID;
                return true;
            }
            return false;
        }

        public static bool checkType(int objectID)
        {
            return Enum.IsDefined(typeof(Castle), objectID);
        }

        public override int GetWidth()
        {
            if (ID == (int)Castle.Big)
            {
                return WidthBig;
            }
            if (ID == (int)Castle.Small)
            {
                return Width;
            }
            return 0;
        }

        public override int GetHeight()
        {
            if (ID == (int)Castle.Big)
            {
                return HeightBig;
            }
            if (ID == (int)Castle.Small)
            {
                return Height;
            }
            return 0;
        }

        public override Bitmap GetBitmap()
        {
            Bitmap src;
            if (!checkType(ID))
            {
                return null;
            }
            switch (ID)
            {
                case (int) Castle.Big:
                    src = Properties.Resources.CastleBig;
                    return MainForm.ResizeImage(src,new Size(WidthBig * MainForm.TileSize,HeightBig * MainForm.TileSize));
                case (int) Castle.Small:
                    src = Properties.Resources.Castle;
                    return MainForm.ResizeImage(src, new Size(Width * MainForm.TileSize, Height * MainForm.TileSize));
            }
            return null;
        }
    }
}
